import express from 'express';
import { UserController } from '../controllers/userController.js';
import { authenticateToken } from '../middleware/auth.js';
import { uploadAvatar } from '../middleware/upload.js';

const router = express.Router();
const userController = new UserController();

// 所有路由都需要token验证
router.use(authenticateToken);

// 获取用户信息
router.get('/profile', userController.getProfile.bind(userController));

// 更新用户信息
router.put('/profile', userController.updateProfile.bind(userController));

// 上传头像
router.post('/avatar', uploadAvatar.single('avatar'), userController.uploadAvatar.bind(userController));

// 删除头像
router.delete('/avatar', userController.deleteAvatar.bind(userController));

// 修改密码
router.put('/password', userController.changePassword.bind(userController));

// 获取用户活动记录
router.get('/activity', userController.getActivity.bind(userController));

export default router;